tuple1 = (1,2,3,"nihao",[7,7,7])
print(tuple1)
print(type(tuple1))
tuple2 = (1.1,)    # 元组内如果只有一个元素,需要在这个元素后添加逗号
print(tuple2)
print(type(tuple2))
# # 尝试修改元组内的数据
# tuple1[0] = "壹"
# =============================
# 元组的查找相关函数
# 根据下标查找
print(tuple1[3])
# 查找某个元素的下标,返回第一个匹配项的下标,找不到则报错
print(tuple1.index("nihao"))
# print(tuple1.index("nihao1"))
# 统计元素个数
print(len(tuple1))
# 判断元素是否在元组内
print("nihao" in tuple1)
print("nihao" not in tuple1)
# 特殊情况:如果元组内有可变数据类型的元素,则这个元素内的数据支持修改
tuple1 = (1,2,3,"nihao",[7,7,7])
print(id(tuple1[-1]))
tuple1[-1][1] = "七"
print(id(tuple1[-1]))
print(tuple1)
# tuple1[-1] = [1,2,3]